<template>
  <div>
    <div style="display:flex;flex-direction:row-reverse;margin-top:10px">
      <el-button :loading="saveLoading" size="mini" type="primary" @click="submitForm">保存</el-button>
    </div>
    <el-form
      ref="refForm"
      style="margin-top:20px"
      :rules="formRules"
      :model="formData"
      size="mini"
      label-width="150px"
    >
      <el-row>
        <el-col :span="8">
          <el-form-item label="复尺资料审核结果:" prop="resurveyReviewResult">
            <el-select
              v-model="formData.resurveyReviewResult"
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option label="同意" :value="1" />
              <el-option label="不同意" :value="0" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="复尺资料审核结果说明:" prop="resurveyReviewResultDesc">
            <el-input v-model="formData.resurveyReviewResultDesc" maxlength="1000" show-word-limit type="textarea" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div style="margin-top:20px" class="qup-title-box"><span class="border" /><span>测绘申请数据</span></div>
    <map-detail :detail-data="id" />
    <div class="qup-title-box"><span class="border" /><span>测绘数据</span></div>
    <map-detail-1 :detail-data="detailData" />
    <div class="qup-title-box"><span class="border" /><span>复尺结果</span></div>
    <el-form
      size="mini"
      label-width="150px"
    >
      <el-row>
        <el-col :span="8">
          <el-form-item label="复尺申请时间:" prop="">
            {{ detailData.resurveyApplyTime }}
          </el-form-item>
        </el-col>
        <el-col :span="16">
          <el-form-item label="复尺申请说明:" prop="">
            {{ detailData.resurveyApplyDesc }}
          </el-form-item>
        </el-col>

      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="是否完成复尺:" prop="">
            {{ detailData.isFinishResurvey===1?'是':'否' }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="实际复尺时间:" prop="">
            {{ detailData.actualResurveyTime }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="本次复尺面积:" prop="">
            {{ detailData.currentResurveyArea +'㎡' }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="复尺人姓名:" prop="">
            {{ detailData.resurveyorName }}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="复尺电话:" prop="">
            {{ detailData.resurveyorPhone }}
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="qup-title-box"><span class="border" /><span>附件管理</span></div>
    <file-detail
      style="margin-top:20px"
      :file-data="formData.shopAttachmentDTOList"
    />
  </div>
</template>
<script>
import fileDetail from '../fileDetail.vue'
import mapDetail from '../mapDetail.vue'
import mapDetail1 from '../mapDetail1.vue'
import BackPageMixin from '@/mixins/backPage'
import { getDictByPatchType } from '@/api/dataDict'
import { getDetailData, saveState } from '@/api/shopMap'
import { getShopAttachment } from '@/api/common.js'

export default {
  name: 'ReMapAudit',
  components: { fileDetail, mapDetail, mapDetail1 },
  mixins: [BackPageMixin],
  props: {},
  data() {
    return {
      id: '',
      saveLoading: false,
      detailData: {}, // 测绘详情
      formRules: {
        resurveyReviewResult: [
          { required: true, message: '请选择复尺资料审核结果', trigger: 'change' }
        ],
        resurveyReviewResultDesc: [
          { required: true, message: '请填写复尺资料审核结果说明', trigger: 'change' }
        ]
      },
      auditResultOptions: [], // 审核结果
      formData: {
        id: '',
        constCode: '',
        decorationRange: '',
        state: '',
        surveyBatchCode: '',
        dataSource: '',
        isNeedResurvey: 0, // 是否需要复尺
        isFinishResurvey: 0, // 是否完成复尺
        unresurveyDesignSetup: 0,
        unresurveyDesignConst: 0,
        resurveyReviewResult: 1,
        resurveyReviewResultDesc: '',
        shopAttachmentDTOList: []// 附件信息
      }
    }
  },
  computed: {
  },
  created() {
    this.id = this.$route.query.id
    if (this.id) {
      this.formData.id = this.id
      this.getFiles()// 获取文件列表信息
      getDetailData(this.id).then(res => {
        if (res.success === 1) {
          this.detailData = res.data
          this.formData.decorationRange = res.data.decorationRange
          this.formData.surveyBatchCode = res.data.surveyBatchCode
          this.formData.dataSource = res.data.dataSource
          this.formData.constCode = res.data.constCode
          this.formData.state = res.data.state
          this.formData.isNeedResurvey = res.data.isNeedResurvey
          this.formData.isFinishResurvey = res.data.isFinishResurvey
          this.formData.unresurveyDesignConst = res.data.unresurveyDesignConst
          this.formData.unresurveyDesignSetup = res.data.unresurveyDesignSetup
        }
      })
    }
    this.getDictByPatchTypeAll()
  },
  methods: {
    // 获取附件
    getFiles() {
      getShopAttachment(this.id).then(res => {
        this.formData.shopAttachmentDTOList = res.data
      })
    },
    async getDictByPatchTypeAll() {
      const { REVIEW_RESULT } =
       await getDictByPatchType(['REVIEW_RESULT'])
      this.auditResultOptions = REVIEW_RESULT
    },
    submitForm() {
      this.$refs['refForm'].validate((valid) => {
        if (valid) {
          this.saveLoading = true
          saveState(this.formData).then(res => {
            if (res.success === 1) {
              this.$message({
                message: '操作成功',
                type: 'success'
              })
              this.saveLoading = false
              this.$store.dispatch('views/goBack')// 返回列表页
            }
          }).catch(() => {
            this.saveLoading = false
          })
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
/deep/ .el-breadcrumb__inner{
    color: $qup-color-primary;
  }
</style>
